<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('监督批次列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <p>状态：</p>
                            <select name="status" class="form-control select2-single">
                                <option value="">---请选择---</option>
                                <option value="50">未日结</option>
                                <option value="100">未监控</option>
                                <option value="150">部分监控</option>
                                <option value="180">正在监控</option>
                                <option value="200">已监控</option>
                            </select>
                        </li>
                        <li class="select-time">
                            <p>日期：</p>
                            <input type="text" class="time-input" onKeyDown="return nextStep(this.form);" id="beginDate" placeholder="开始日期" name="beginDate"/>
                            <span>-</span>
                            <input type="text" class="time-input" onKeyDown="return nextStep(this.form);" id="endDate" placeholder="结束日期" name="endDate"/>
                        </li>

                        <li>
                            <p>机构号：</p>
                            <input name="orgId" onclick="selectDeptTree()"  id="treeId" type="text" placeholder="请选择" class="form-control">
                        </li>

                        <li>
                        <p>柜员号</p>
                            <input name="tellerId" type="text" class="form-control">
                        </li>

                        <input type="hidden" name="queryFlag" th:value="${queryFlag}">
                        <input type="hidden" name="auditorId" th:value="${userId}">

                        <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                        <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="audit()">
                <i class="fa fa-plus"></i> 开始监控
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var prefix = ctx + "oms/paeaAuBatch";
    var statusDatas = [[${@dict.getType('paea_au_batch_status')}]];

    $(function() {
        var options = {
            url: prefix + "/queryList",
            exportUrl: prefix + "/export",
            striped: true,
            clickToSelect: true,
            onDblClickRow:audit,
            modalName: "监控批次",
            columns: [{
                radio: true
            },
                {
                    field : 'id',
                    title : 'id',
                    visible: false
                },
                {
                    field : 'orgId',
                    title : '机构号'
                },
                {
                    field : 'batchType',
                    title : '监控类型'
                },
                {
                    field : 'trDate',
                    title : '交易日期'
                },
                {
                    field : 'finishNum',
                    title : '已监控数量'
                },
                {
                    field : 'auItemNum',
                    title : '监控总数'
                },
                {
                    field : 'status',
                    title : '状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                {
                    field : 'limitDate',
                    title : '监控期限'
                }]
        };
        $.table.init(options);
    });

    //选择机构
    function selectDeptTree() {
        var treeId = $("#treeId").val();
        var deptId = $.common.isEmpty(treeId) ? "00038" : $("#treeId").val();
        var url = ctx + "system/dept/selectDeptTree/" + deptId;
        var options = {
            title: '选择部门',
            width: "380",
            url: url,
            callBack: doSubmit
        };
        $.modal.openOptions(options);
    }

    function doSubmit(index, layero){
        var tree = layero.find("iframe")[0].contentWindow.$._tree;
        if ($.tree.notAllowParents(tree)) {
            var body = layer.getChildFrame('body', index);
            $("#treeId").val(body.find('#treeId').val());
            layer.close(index);
        }
    }

    //监控批次
    function audit() {
        var row = $("#bootstrap-table").bootstrapTable('getSelections')[0];
        if(row==null){
            //$.modal.alertWarning("请先选择一条记录");
            $.modal.msgWarning("请先选择一条记录！");
            return;
        }
        var beginDate = document.getElementById('beginDate').value;
        var endDate = document.getElementById('endDate').value;
        window.returnValue= row.id+"#"+beginDate+"#"+endDate+"#"+row.orgId+"#"+row.batchType+"#"+row.status;
        window.close();
    }
</script>
</body>
</html>